/**
 * Fuzzy Refrigerator: Refrigerator with Fuzzy Logic as temperature controller
 * Copyright (C) 2012  Izwan Azmi
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

 /**
  * @file main.cpp
  * @brief Bahagian utama perisian Fuzzy Refrigerator
  * @author Izwan Azmi <izwanazmi90@gmail.com>
  */


#include "refrigerator.h"

#include <iostream>
#include <fstream>

using namespace std;

int main(int argc, char *argv[])
{
    // If the user didn't provide a filename command line argument,
    // print an error and exit.
    if (argc <= 1)
    {
        cout << "Usage: " << argv[0] << " <Filename>" << endl;
        return 1;
    }

    char *pFilename = argv[1];

    ifstream ifs;
    ifs.open(pFilename);

    // Semak saiz kes
    int kes;
    ifs >> kes;

    // Proses semua kes
    refrigerator *ref = new refrigerator();
    float temp, rate_change_temp;
    for(int i = 0; i < kes; i++)
    {
        ifs >> temp >> rate_change_temp;
        cout << "Kes: " << i + 1 << endl;
        cout << "Suhu: " << temp << endl;
        cout << "Kadar perubahan suhu: " << rate_change_temp << endl;
        cout << "Kadar tenaga diperlukan: " << ref->start(temp, rate_change_temp) << endl << endl;

        ref->report(i);   // Make report
    }

    ifs.close();

    //delete ref;
    return 0;
}


